import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
import shareActions from "@/qiankunApi";

Vue.config.productionTip = false

let instance = null;
function render( props = {}) {
    const { container,microStore } = props;
    console.log(microStore)
    if(microStore){ // 主应用的store
        console.log(microStore)
        // shareActions.setGlobalState(props)
    }
    instance = new Vue({
        router,
        store,
        render: h => h(App),
    }).$mount(container ? container.querySelector('#app'): '#app');  // 为了避免根id#app与其他DOM冲突，需要限制查找范围
}

if (!window.__POWERED_BY_QIANKUN__) {
    render();
}



//--------- 生命周期函数------------//
export async function bootstrap() {
  console.log('[vue] vue app bootstraped');
}
export async function mount(props) {
    render(props);
}
export async function unmount() {
  instance.$destroy();
  instance.$el.innerHTML = '';
  instance = null;
}
